﻿using System;
using System.Xml;

/// <summary>
/// SysSettings 的摘要说明
/// </summary>
public class SysSettings
{
    public SysSettings()
    {
        //
        // TODO: 在此处添加构造函数逻辑
        //
    }

    public static string GetSysSetting(string settingName)
    {
        string str = string.Empty;
        XmlDocument xmlDoc = new XmlDocument();
        xmlDoc.Load(System.Web.HttpContext.Current.Server.MapPath("~/System/SysConfig/SysConfig.xml"));
        XmlNodeList xmlNodeList = xmlDoc.SelectNodes("settings/setting[title='" + settingName + "']");
        if (xmlNodeList.Count == 0)
            return str;
        XmlNode xmlNode = xmlNodeList.Item(0);
        if (xmlNode != null)
        {
            str = xmlNode["content"].InnerText;
        }
        return str;
    }

    public static string GetTDMaxLength()
    {
        return GetSysSetting("表格单元格显示文字最大长度");
    }

    public static string GetPageSize()
    {
        return GetSysSetting("每页记录数");
    }
    public static string GetHeadTitle()
    {
        return GetSysSetting("系统标题");
    }
    public static string GetSysEmail()
    {
        return GetSysSetting("系统邮箱");
    }
    public static string GetDefaultEmail()
    {
        return GetSysSetting("默认邮箱");
    }
    public static string GetDefaultMailSubject()
    {
        return GetSysSetting("通知邮件标题");
    }
    public static string GetDefaultMailBody()
    {
        return GetSysSetting("通知邮件内容");
    }
    public static int GetSessTimeout()
    {
        int min = 30;
        int.TryParse(GetSysSetting("Session有效时间"), out min);
        return min;
    }
    public static string GetPublishInfo()
    {
        return GetSysSetting("版权信息");
    }
    public static string GetSysPath()
    {
        return GetSysSetting("系统访问地址");
    }
    public static int? GetListDecimalDigits()
    {
        int digits;
        if (int.TryParse(GetSysSetting("列表小数位数"), out digits))
            return digits;
        else
            return null;
    }
    public static string GetLinks()
    {
        return GetSysSetting("友情链接");
    }
    public static string GetCompanyName()
    {
        return GetSysSetting("单位名称");
    }    
}
